(require 'pyim)
(require 'pyim-basedict) ; 拼音词库设置，五笔用户 *不需要* 此行设置
(pyim-basedict-enable)   ; 拼音词库，五笔用户 *不需要* 此行设置
(setq default-input-method "pyim")

;; 这个函数是为了解决这个issue https://github.com/tumashu/pyim/issues/402
(defun pyim-add-unread-command-events (key &optional reset)
  (when reset
    (setq unread-command-events nil))
  (setq unread-command-events
        (if (characterp key)
            (cons key unread-command-events)
          (append (mapcan (lambda (e) (list e))
                          (append key nil))
                  unread-command-events))))

(provide 'pyim-init)
